package com.macro.mall.common.exception;


import com.macro.mall.common.enums.BizCode;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

/**
 * @author xiqixaun
 * @date 2024/03/05
 */
@Slf4j
public class BaseException extends RuntimeException {
    private IResultStatus status;
    private Object info;
    @Getter
    @Setter
    private String invokeLine;

    public BaseException(IResultStatus status) {
        super(status.getMsg());
        this.status = status;
    }

    public BaseException(IResultStatus status, Object info) {
        super(status.getMsg());
        this.status = status;
        this.info = info;
    }


    public BaseException(String msg) {
        super(msg);
        this.status = new ExceptionCode(msg);
    }

    public BaseException(BizCode bizCode){
        this(bizCode.getCode(), bizCode.getMessage());
    }
    public BaseException(int code, String msg) {
        super(msg);
        this.status = new ExceptionCode(code, msg);
    }

    public BaseException(String message, Throwable cause) {
        super(message, cause);
    }

    public BaseException(IResultStatus status, String msg, Throwable cause) {
        super(msg, cause);
        this.status = new ExceptionCode(status.getCode(), msg);
    }

    public IResultStatus getStatus() {
        return this.status;
    }

    public Object getInfo() {
        return this.info;
    }

    public void setStatus(IResultStatus status) {
        this.status = status;
    }
}
